/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvc.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import mvc.modelos.DirectorDeGrupo;

/**
 *
 * @author pezcado
 */
public class DirectorDeGrupoDAO{
    private PreparedStatement consultar;
    private PreparedStatement insertar;
    private PreparedStatement modificar;
    private PreparedStatement eliminar;
    private PreparedStatement listar;
    private Model model;

    public DirectorDeGrupo consultar(int ide) throws SQLException {
        String sql="select identificacion from Director_De_Grupo where identificacion="+ide;
        consultar= model.getCon().prepareStatement(sql);
        ResultSet resultSet= consultar.executeQuery();
        DirectorDeGrupo directorDeGrupo= new DirectorDeGrupo();
        
        try{
            resultSet.next();
            
            directorDeGrupo.setIdentificacion(resultSet.getInt("identificacion"));
            
        }catch(Exception e){
            
        }
        return directorDeGrupo;
    }

    public void insertar(DirectorDeGrupo IDAO) throws SQLException {
        model.getInstance();
        try{
            if(insertar==null){
                String sql="insert into Director_De_Grupo values(?)";
                insertar= model.getCon().prepareStatement(sql);
            }
            
            insertar.setInt(1, IDAO.getIdentificacion());
            
             insertar.executeUpdate();
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    public void modificar(DirectorDeGrupo IDAO) throws SQLException {
        
    }

    public void eliminar(DirectorDeGrupo IDAO) throws SQLException {
        model=Model.getInstance();
        
        String sql="delete from Director_De_Grupo where identificacion="+IDAO.getIdentificacion();
        eliminar=model.getCon().prepareStatement(sql);
        
        eliminar.executeUpdate();
    }

    public LinkedList<DirectorDeGrupo> listar() throws SQLException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}